package com.example.guet_assistant.controller;


import com.example.guet_assistant.context.BaseContext;
import com.example.guet_assistant.domain.dto.PageDTO;
import com.example.guet_assistant.domain.vo.PageVO;
import com.example.guet_assistant.pojo.entity.Tool;
import com.example.guet_assistant.result.Result;
import com.example.guet_assistant.service.ToolService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author author
 * @since 2024-11-13
 */
@Tag(name="工具管理接口")
@RestController
@RequestMapping("/tool")
public class ToolController {
    @Autowired
    private ToolService toolService;



    @Operation(summary = "分页返回全部常用工具列表")
    @GetMapping
    public Result<PageVO<Tool>> getCommonTools(@ParameterObject PageDTO pageDTO){
         return  Result.success(toolService.getCommonTools(pageDTO));
    }



    @Operation(summary = "根据用户id获取常用工具")
    @GetMapping("{userId}")
    public  Result<List<Tool>> getUserTools(@PathVariable("userId")  Long userId){
        return  Result.success(toolService.getUserTools(userId));
    }




    @Operation(summary = "用户批量删除常用工具")
    @DeleteMapping("{ids}")
    public Result delete(@PathVariable List<Integer> ids){
                toolService.removeUserTools(ids);
                return Result.success();
    }




    @Operation(summary = "用户批量新增常用工具")
    @PutMapping("{ids}")
    public Result addUserTools(@PathVariable List<Integer> ids) {
        toolService.addUserTools(ids);
        return Result.success();
    }
}
